package com.agy.filemanager.toolClass;

public class ResultUtil {

    /**
     * 请求成功返回
     * @param data
     * @return
     */
    public static Result success(Object data,String msg){
        Result result = new Result();
        result.setSuccess(true);
        result.setMessage(msg);
        result.setData(data);
        return result;
    }
    /**
     * 请求成功返回
     * @param data
     * @return
     */
    public static Result success(Object data,String msg,String code){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        result.setData(data);
        return result;
    }
    public static Result success(Object data){
        Result result = new Result();
        result.setMessage("请求成功");
        result.setSuccess(true);
        result.setData(data);
        return result;
    }
    public static Result success(String msg){
        return success(null,msg);
    }
    /**
     * 请求失败返回
     * @param msg
     * @return
     */
    public static Result error(String msg){
        Result result = new Result();
        result.setSuccess(false);
        result.setMessage(msg);
        return result;
    }

    public static Result error(String code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(msg);
        result.setSuccess(false);
        return result;
    }
}
